#
# modified from ACE_wrappers\include\makeinclude\platform_linux.GNU
#

#debug ?= 0
#optimize ?= 1
#profile ?= 1
disable_assert=1
leak_check = 0
flow_control = 1
exceptions ?= 1
threads ?= 1
softdog ?= 
use_micro_dog = 

ifeq (,$(debug))
  debug = 1
endif
ifeq (,$(optimize))
  optimize = 0
endif
ifeq (,$(profile))
  profile = 0
endif
ifeq (,$(disable_assert))
  disable_assert = 0
endif



DEFFLAGS += -DRT_UNIX 
SYSTEM = $(shell uname -s)
ifeq ($(SYSTEM), Linux)
  DEFFLAGS += -DRT_LINUX
endif

MACHINE = $(shell uname -m)
ifeq ($(MACHINE), x86_64)
  x86_64 = 1
else
  x86_64 = 0
endif

ifeq (1,$(profile))
  DEFFLAGS += -pg
endif # debug

CC  = gcc
CPP = g++

LINUX_FLAGS = -Wall -Wpointer-arith -pipe -D__STDC_CONSTANT_MACROS -rdynamic
CFLAGS  += $(LINUX_FLAGS)
CPPFLAGS += $(LINUX_FLAGS)
ifeq ($(threads),1)
  CPPFLAGS  += -D_REENTRANT
endif # threads

# 
# Rely on _GNU_SOURCE to set these defaults defined in /usr/include/features.h 
# instead of setting them directly here (older versions of gcc don't set it
# for you): _SVID_SOURCE _BSD_SOURCE _POSIX_SOURCE _POSIX_C_SOURCE=199506L, etc...
CPPFLAGS += -D_GNU_SOURCE

DCFLAGS += -g

#OPTFLAGS += -O2
OPTFLAGS += -O3
LD      = $(CXX)
LIBS    += -ldl

ifeq ($(threads),1)
  LIBS += -lpthread
endif
LIBS += $(shell test -e /usr/lib/librt.so && echo -lrt)

OCFLAGS += -O3
PIC     = -fPIC
AR      = ar
ARFLAGS = rsuv
RM      = rm -rf

ifeq ($(debug),1)
  NASMFLAG = -g
else
  NASMFLAG = -O3
endif
